
$regfile = "m16def.dat"
$crystal = 8000000
$baud = 19200                                               ' use baud rate
Dim Input_pinb As Integer , Icounter As Integer
Dim Winput_adc As Word
Config Timer0 = Timer , Prescale = 1024
Config Adc = Single , Prescaler = Auto
'Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0




Start Adc

Icounter = 0
Config Portc = Output
Portb = &HFF


Enable Interrupts
Enable Timer0                                               'enable the interrupt
On Timer0 Fint_handle_timer0

Start Timer0
Waitms 1000
Print
Print "TEST"

Do
Loop                                                        'loop until users presses ESC key
End



Fint_handle_timer0:
   Icounter = Icounter + 1
   If Icounter > 2 Then
      Winput_adc = Getadc(0)
      'If Winput_adc > 500 Then
      '   Portc = &HFF
      'End If
      Icounter = 0
      Winput_adc = Winput_adc * 255
      Winput_adc = Winput_adc / 1024
      Portc = Winput_adc 
   End If
   Input_pinb = Pinb And 1
   'Input_pinb = 0
   If Pinb.0 = 0 Then
      Portc = &H0F
   End If
Return                                                      'notice the return
End